


const http = require('http')
const url = require('url')
const fs = require('fs')

let server = http.createServer()
server.on('request',(req,res)=>{
    console.log(req.url);
    let urlObj = url.parse(req.url,true)
    console.log(req.method);
    // 异步读取
    fs.readFile('./views/index.html','utf8',(err,data)=>{
        if(err){
            throw err
        }
        res.write(data)
        res.end()   
    })
    
   
})

server.listen(3001,()=>{
    console.log(`server is running...`);
})